package cn.bellychang.interceptor2;

import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ChangLiang
 * @date 2020/9/8
 */
@Configuration
public class InterceptorAnnotationConfig {

    @Bean
    public DefaultPointcutAdvisor defaultPointcutAdvisor3() {
        TracingInterceptor interceptor = new TracingInterceptor();

        AnnotationMatchingPointcut pointcut = new AnnotationMatchingPointcut(null, HfiTrace.class);

        /*JdkRegexpMethodPointcut pointcut = new JdkRegexpMethodPointcut();
        pointcut.setPatterns("cn.bellychang.aop.*");*/

        // 配置增强类advisor
        DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
        advisor.setPointcut(pointcut);
        advisor.setAdvice(interceptor);
        return advisor;
    }
}
